﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddDutyGrade.aspx.cs" Inherits="ZX.WebApp.EditWidows.OrganizationalManager.AddDutyGrade" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/connection/connection-min.js"></script>
    <script src="../../Scripts/jquery-1.6.min.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.json-2.2.min.js" type="text/javascript"></script>
    <script src="../../Scripts/Jquery.form.js" type="text/javascript"></script>
    <link href="../../Styles/extendTable.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table class="tableContent" id="DutyGradeTable">
            <tr>
                <td style="height:30px; width:100px;">
                    职位名称：
                </td>
                <td>
                    <input type="hidden" id="PostID" runat="server" />
                    <%--<asp:Label ID="Name" runat="server"></asp:Label>--%>
                    <asp:TextBox ID="Name" ReadOnly="true" runat="server"
                         Height="20"></asp:TextBox>
                    <span style="color: Red">*</span>
                </td>
            </tr>
            <tr>
                <td style="height:30px; width:100px;">
                    职级：</td>
                <td>
                    <asp:DropDownList ID="DutyGradeId" name="DutyGradeId" Width="155" Height="25"
                            runat="server" AppendDataBoundItems="true">
                        <asp:ListItem Value=""> </asp:ListItem>
                    </asp:DropDownList>
                    <span style="color: Red">*</span>
                </td>
            </tr>
            <input type="hidden" id="ID" runat="server" />       
        </table>       
    </div> 
    </form>
</body>
<script type="text/javascript">
    var dutyId = "<%=DutyId %>", Entity = "<%=EntityNames %>",Url="";
    var instance = [{ "ID": "", "PostID": "", "DutyGradeId": ""}];
    function Save() {
        var vDutyInfoId = $("#PostID").val();
        var vDutyGradeId = $("#DutyGradeId").find("option:selected").val()
        var ID = $("#ID").val();
        if (vDutyInfoId == "") {
            alert("职务名称不能为空!");
            return;
        } else {
            $("#DutyGradeTable").SetFormValueToObject(instance[0]);
            if (vDutyGradeId == "") {
                alert("职级不能为空!");
                return;
                /*if (confirm("您确定职级为空?")) {
                    instance[0].DutyGradeId = "00000000-0000-0000-0000-000000000000";
                    SaveData();
                }*/
            } else {
                SaveData();
            }
        }
    }
    function SaveData() {
        var json = $.toJSON(instance[0]).replace(/'/g, "[B]");
        Url = "DataProcessin.aspx?entity=" + Entity + "&action=Insert&json=" + json;
        YAHOO.util.Connect.asyncRequest('POST', Url, {
            success: function (res) {
                var inventory;
                try {
                    inventory = res.responseText;
                    if (inventory == 1) {
                        alert("保存成功!");
                        parent.LoadDataById();
                    } else {
                        alert(inventory);
                    }
                }
                catch (e) {
                }
                finally {
                }
            },
            failure: function (error) {
                alert("数据错误：" + error.statusText);
            }
        }, null);
    }
</script>
</html>
